<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript" src="js/test1.js"></script>
</head>
<body>
    <h2>prototype</h2>
    <script>
        function Person(name){
            this.myName = name;
        }
        Person.prototype.setMyName = function (name){
            this.myName = name;
        }
        Person.prototype.getMyName = function (){
            return this.myName;
        }
        function Man(name){
            Person.call(this);
            this.myName = name;
        }
        Man.prototype = new Person();
        Man.prototype.shout = function(){
            console.log(this.myName + " get power!");
        }

        var p = new Person("Tom");
        console.log(p.getMyName());
        p.setMyName("Tom1");
        console.log(p.getMyName());

        var man1 = new Man("jack");
        console.log(man1.getMyName());
        man1.shout();
        console.log(man1 instanceof Person);
        console.log(man1 instanceof Man);
    </script>
</body>
</html>